<!DOCTYPE html>
<!-- 给当前的页面来指定命名空间 -->
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>测试thymeleaf的使用</title>
    <style>
        table {
            width: 800px;
            border-collapse: collapse;
        }
        .aaa {
            background-color: gainsboro;
        }
    </style>
</head>
<body>
<h1>显示值</h1>
你好,<span th:text="${loginUser}"></span>
<br />
你好,<span th:text="${ #request.getAttribute('loginUser') }"></span>
<h1>判断</h1>
<div th:if="${ age >= 18 }">
    成年人
</div>
<div th:unless="${ age >= 18 }">
    未成年人
</div>
<h1>循环</h1>
<table border="1">
    <thead>
    <tr class="aaa">
        <th>编号</th>
        <th>名字</th>
        <th>性别</th>
        <th>年龄</th>
        <th>出生日期</th>
    </tr>
    </thead>
    <tbody>
    <tr th:each="student : ${ studentList }" th:class="${ studentStat.odd } ? '' : 'aaa'">
        <td th:text="${student.id}"></td>
        <td th:text="${student.stuName}"></td>
        <td th:text="${student.gender}"></td>
        <td th:text="${student.age}"></td>
        <td th:text="${ #dates.format(student.birthday, 'yyyy-MM-dd') }"></td>
    </tr>
    </tbody>
</table>
<h1>日期的格式化</h1>
<div th:text="${ #dates.format(myBirthday, 'yyyy-MM-dd') }"></div>
<div th:text="${ myLocalDateTime }"></div>
<div th:text="${ #temporals.format(myLocalDateTime, 'yyyy-MM-dd HH:mm:ss') }"></div>
</body>
</html>